<%@include file="template/configuration.jsp" %>
<%@page import="models.Employee"%>
<%@page import="java.util.List"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>${website} || View student assignments</title>
        ${stylesheet}
        ${jquery}
        ${jsdropdown}
        ${jstooltip}
    </head>
    <body>
        <div class="container">

            <%@include file="template/header.jsp" %>
            <div class="content">
                <h1>Assignments from ${student.firstname} ${student.insertion} ${student.lastname} in ${course_name}</h1>
                <div class="full-block">
                    <table class="overview">
                        <tr>
                            <th>Filename</th>
                            <th>Original filename</th>
                            <th class="date">Date added</th>
                            <th style="width: 76px;">Handed in</th>
                            <th style="width: 60px;">Grade</th>
                            <th class="single-icon">Grading</th>
                        </tr>

                        <c:forEach items="${allassignments}" var="allassignments">
                            <c:set var="i" value="${i + 1}"/>
                            <tr class="pointer <c:choose><c:when test="${i % 2 == 0}">even</c:when><c:otherwise>odd</c:otherwise></c:choose>" onclick="">
                                <td>${allassignments.name}</td>
                                <td>${allassignments.fileName}</td>
                                <td><center>
                                <c:set var="handed_in" value="false"/>    
                                <c:forEach items="${assignmenthandin}" var="assignmenthandin">
                                    <c:if test="${assignmenthandin.assignment.id==allassignments.id}">
                                        <c:set var="handed_in" value="true"/>
                                        <c:set var="datetje" value="${assignmenthandin.date}"/> 
                                    </c:if>
                                </c:forEach>
                                <c:if test="${handed_in==true}">${datetje}</c:if>
                                <c:if test="${handed_in==false}">-</c:if></center>
                            </td>
                                <td><center>
                                <c:set var="handed_in" value="false"/>    
                                <c:forEach items="${assignmenthandin}" var="assignmenthandin">
                                    <c:if test="${assignmenthandin.assignment.id==allassignments.id}">
                                        <c:set var="handed_in" value="true"/>
                                    </c:if>
                                </c:forEach>
                                    <c:if test="${handed_in==true}">Yes</c:if>
                                <c:if test="${handed_in==false}">No</c:if></center>
                            </td>
                            <td><center>
                                <c:set var="handed_in" value="false"/>    
                                <c:forEach items="${assignmenthandin}" var="assignmenthandin">
                                    <c:if test="${assignmenthandin.assignment.id==allassignments.id}">
                                        <c:set var="grade" value="${assignmenthandin.grade}"/>
                                        <c:if test="${grade ne '0'}"><c:set var="gradex" value="${grade}"/>  <c:set var="handed_in" value="true"/></c:if>
                                    </c:if>
                                </c:forEach>
                                <c:if test="${handed_in==true}">${gradex}</c:if>
                                <c:if test="${handed_in==false}">-</c:if></center>
                            </td>
                            <td>
                            <center>
                                <c:set var="handed_in" value="false"/>    
                                <c:forEach items="${assignmenthandin}" var="assignmenthandin">
                                    <c:if test="${assignmenthandin.assignment.id==allassignments.id}">
                                        <c:set var="handed_in" value="true"/>
                                        <c:set var="handinurl" value="${assignmenthandin.url}"/> 
                                    </c:if>
                                </c:forEach>
                                <c:if test="${handed_in==true}"><a href="${url}${handinurl}" class="hidden"><img src="${url}images/view.png"/></a></c:if>
                                
                                 <c:set var="handed_inx" value="false"/>    
                                <c:forEach items="${assignmenthandin}" var="assignmenthandin">
                                    <c:if test="${assignmenthandin.assignment.id==allassignments.id}">
                                        <c:set var="handed_inx" value="true"/>
                                        <c:set var="studentid" value="${assignmenthandin.student.id}"/> 
                                      
                                    </c:if>
                                </c:forEach>
                                <c:if test="${handed_inx==true}">
                                    <a href="../ManageGrade?courseid=${courseid}&studentid=${studentid}&assignmentid=${allassignments.id}"><img src="${url}images/editgrades.png"/></a>
                                </c:if>
                                <c:if test="${handed_inx==false}"> <a href="../ManageGrade?courseid=${courseid}&studentid=${student.id}&assignmentid=${allassignments.id}"><img src="${url}images/editgrades.png"/></a></c:if>
                                </center></td>
                                
                           
                    </tr>
                        </c:forEach>
                    </table>
                </div>
            </div>
            <%@include file="template/footer.jsp" %>
        </div>
    </body>
</html>
